package com.numberone.master.modules.agent.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.numberone.master.common.service.TreeService;
import com.numberone.master.common.utils.StringUtils;
import com.numberone.master.modules.agent.entity.Agent;
import com.numberone.master.modules.agent.dao.AgentDao;

/**
 * 代理商Service
 * @author chengkang
 * @version 2018-01-23
 */
@Service
@Transactional(readOnly = true)
public class AgentService extends TreeService<AgentDao, Agent> {

	public Agent get(String id) {
		return super.get(id);
	}
	
	public List<Agent> findList(Agent agent) {
		if (StringUtils.isNotBlank(agent.getParentIds())){
			agent.setParentIds(","+agent.getParentIds()+",");
		}
		return super.findList(agent);
	}
	
	@Transactional(readOnly = false)
	public void save(Agent agent) {
		super.save(agent);
	}
	
	@Transactional(readOnly = false)
	public void delete(Agent agent) {
		super.delete(agent);
	}
	
}